package com.lihegang.example.util.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * amqp 队列配置
 *
 * @author wujing
 */
@Configuration
public class AmqpConfiguration {

    @Bean(name="amqp")
    public Queue queue() {
        return new Queue("rabbit.queue");
    }

    @Bean
    public Queue topicQueue(){
        return new Queue("topic_queue",true);
    }

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("topic_exchange");
    }

    @Bean
    public Binding topicBinding(){
        return BindingBuilder.bind(topicQueue()).to(topicExchange()).with("topic_key1");
    }
}